package com.hzit.pay.center.customer;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

/**
 * 设置mq消息的ttl
 */
public class MyMessagePostProcessor implements MessagePostProcessor {

    private final long ttl;

    public MyMessagePostProcessor(final long ttl){
        this.ttl = ttl;
    }


    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
        message.getMessageProperties().getHeaders().put("expiration", String.valueOf(ttl));
        return message;
    }
}
